import java.util.*;
import java.util.Map.Entry;

public class EllysJuice {

	static final int MAX_FACTORIALS = 20;
	static long[] factorials = new long[MAX_FACTORIALS+1];
	static {
		factorials[0] = 1;
		for (int i=1; i<=MAX_FACTORIALS; i++) factorials[i] = factorials[i-1]*i;
	}
	
	public static long factorial(int n) {
		assert n >= 0;
		assert n <= MAX_FACTORIALS;
		return factorials[n];
	}
	
	public static int[] factRadixToPermutation(long x, int n) {
		assert x < factorials[n];
		boolean[] used = new boolean[n];
		int[] res = new int[n];
		for (int i=1; i<=n; i++) {
			int p = (int)(x / factorials[n-i]);
			for (int j = 0, cnt = 0;;j++) {
				if (!used[j]) {
					if (cnt < p) cnt++;
					else {
						res[i-1] = j;
						used[j] = true;
						break;
					}
				}
			}
			x = x - p*factorials[n-i];
		}
		return res;
	}
	
	public static  Iterator<int[]> generatePermutations(final int n) {
		assert n > 0;
		return new Iterator<int[]>() {			
			int nxtNumber = 0;
			
			public boolean hasNext() {				
				return nxtNumber < factorials[n];
			}
			
			
			public int[] next() {
				int p = nxtNumber++;
				return factRadixToPermutation(p, n);
			}
			
			
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}	
	
	public String[] getWinners(String[] players) {
		HashSet<String> res = new HashSet<String>();
		HashMap<String, Double> map = new HashMap<String, Double>();
		
		for (Iterator<int[]> it = generatePermutations(players.length); it.hasNext();) {
			map.clear();
			int[] p = it.next();
			int div = 1;
			for (int i=0; i<players.length; i++) {
				if (i%2 == 0) div *= 2;
				String key = players[p[i]];
				Double amount = map.get(key);
				if (amount == null) amount = 0.0;
				amount += 1.0/div;
				map.put(key, amount);
			}
			
			double max = 0;
			String key = "";
			for (Entry<String, Double> en: map.entrySet()) {
				if (en.getValue() == max) {
					key = "";
				}
				if (en.getValue() > max) {
					max = en.getValue();
					key = en.getKey();
				}				
				
			}
			if (!key.equals("")) res.add(key);
		}
		
		
		String[] ret = res.toArray(new String[0]);
		Arrays.sort(ret);
		return ret;
	}	
}
